<?php
/**
 * Created by PhpStorm.
 * User: mojie126
 * Date: 2017/6/7
 * Time: 下午8:55
 */

namespace app\common;


class omdb
{
	static public function getIMDbRating($imdburl)
	{
		$imdb = "";
		if (preg_match("/[0-9]+/", $imdburl, $matches)) {
			$imdb = sprintf("%07d", $matches[0]);
		}
		$apikey = "b997b67b";//申请到的API Key一直不能用
		$url = "http://www.omdbapi.com/?i=tt$imdb&apikey=$apikey";
		$imdb = json_decode(mycurl($url));
		if ($imdb->Response === "False") {
			return "";
		} else {
			if (@$imdb->imdbRating) {
				return $imdb->imdbRating;
			} else {
				return "";
			}
		}
	}
}